package base.utils;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
 * Created by 30509 on 2018/3/18.
 */
public class ChangeUtils {
    public static int  parseInt(String str,int def) {
        int result =def;
        try {
            result=Integer.parseInt(str);


        }catch (Exception e) {
            return def;
        }

        return result;
    }
    public static Date stringToDate(String source, String pattern) {
        SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
        Date date = null;
        try {
            date = simpleDateFormat.parse(source);
        } catch (Exception e) {
        }
        return date;
    }
    public static java.sql.Date strToDate(String strDate) {
        String str = strDate;
        SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
        java.util.Date d = null;
        try {
            d = format.parse(str);
        } catch (Exception e) {
            e.printStackTrace();
        }
        java.sql.Date date = new java.sql.Date(d.getTime());
        return date;
    }

    public static void main(String[] args) {

    }

}
